﻿Imports DTO
Public Class MuaHangChiTietDAO
    Public Shared Function LoadMuaHangChiTiet(MaPhieuMuaHang As String) As DataTable
        Dim sql As String = String.Format("Select * From MuaHangChiTiet Where MaPhieuMuaHang='{0}'", MaPhieuMuaHang)
        Return CKetNoi.GetData(sql)
    End Function

    Public Shared Function Insert(muaHangChiTiet As MuaHangChiTietDTO) As Boolean
        Dim sql As String = String.Format("Insert Into MuaHangChiTiet(MaPhieuMuaHang,MaHangHoa,SoLuong,DonGia) Values ('{0}','{1}',{2},{3})",
                                          muaHangChiTiet.MaPhieuMuaHang, muaHangChiTiet.MaHangHoa, muaHangChiTiet.SoLuong, muaHangChiTiet.DonGia)
        Dim Count As Integer = CKetNoi.ExecNonQuery(sql)
        If Count > 0 Then
            Return True
        Else
            Return False
        End If
    End Function

    Public Shared Function Update(muaHangChiTiet As MuaHangChiTietDTO) As Boolean
        Dim sql As String = String.Format("Update MuaHangChiTiet Set MaPhieuMuahang='{0}',MaHangHoa='{1}',SoLuong={2},DonGia={3}",
                                           muaHangChiTiet.MaPhieuMuaHang, muaHangChiTiet.MaHangHoa, muaHangChiTiet.SoLuong, muaHangChiTiet.DonGia)
        Dim Count As Integer = CKetNoi.ExecNonQuery(sql)
        If Count > 0 Then
            Return True
        Else
            Return False
        End If
    End Function
End Class
